package com.pengtu.gsj.controller.checker;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.pengtu.gsj.entity.check.CheckProject;
import com.pengtu.gsj.service.check.CheckProjectService;
import org.apache.commons.lang.StringUtils;
import com.pengtu.gsj.utils.web.SpringMvcUtils;


@Controller
@RequestMapping("provinceTable")
public class ProvinceTableController {
	
	@Autowired
	private CheckProjectService checkProjectService;
	
	@ModelAttribute
	public void load(String projectId, Model model) {
		CheckProject checkProject;
		if (StringUtils.isNotEmpty(projectId)) {
			checkProject = checkProjectService.getCheckProject(projectId);
			model.addAttribute("projectId", projectId);
		} else {
			checkProject = new CheckProject();
		}
		model.addAttribute("menuList", checkProject.getMenuList());
		model.addAttribute("parentId", SpringMvcUtils.getParameter("parentId"));
		model.addAttribute("left", SpringMvcUtils.getParameter("left"));
		model.addAttribute("checkProject", checkProject);
	}

	@RequestMapping("show")
	public String showCheckContent(@ModelAttribute CheckProject checkProject, Model model) {
		System.out.println("name:"+checkProject.getProjectName());
		System.out.println("size:"+checkProject.getTableSysmenu());
		model.addAttribute("checkList", checkProject.getTableSysmenu());
		return "check/province/list";
	}
	
}
